package vip.meet.datasource;

import org.springframework.util.Assert;

public class DataSourceKeyThreadHolder {
    // 同一个线程持有相同的key
    private static final ThreadLocal<String> dataSourcesKeyHolder = new ThreadLocal<String>();

    public static void setDataSourceKey(String customerType) {
        Assert.notNull(customerType, "DataSourceKey cannot be null");
        dataSourcesKeyHolder.set(customerType);
    }

    public static String getDataSourceKey() {
        return dataSourcesKeyHolder.get();
    }

    public static void clearDataSourceKey() {
        dataSourcesKeyHolder.remove();
    }
}
